import request from '@/utils/request'
import { mapState, mapActions, mapMutations,mapGetters } from "vuex";
// const setSelectedId = ''

/**
 * 获取所有活动
 * @param params 值
 * @returns {AxiosPromise}
 */
export function getCompanyListApi(id,params) {
  return request({
    url: `/api/Companies/${id}`,
    method: 'GET',
    headers: {
      isToken: true,
      Accept: 'application/json'
    },
    params: Object.assign(params)
  });
};

/**
 * 获取单个公司
 * id 值
 * @returns {AxiosPromise}
 */
export function getCompanyIdApi(selectedId,id) {
  return request({
    url: `/api/Companies/${selectedId}/${id}`,
    method: 'GET',
    headers: {
      isToken: true,
      Accept: 'application/json'
    }
  });
};

/**
 * 添加活动
 *  @param data 参数
 */
export function postCompanyApi(id,data) {
  return request({
    url: `/api/Companies/${id}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json', // 添加 Content-Type 头部
      'Accept': 'application/json'
    },
    data
  });
};

/**
 * 更新活动
 *  @param data 参数
 *  id 参数
 */
export function putCompanyApi(selectedId,id,data) {
  return request({
    url: `/api/Companies/${selectedId}/${id}`,
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    },
    data
  });
};

/**
 * 删除活动
 * @param data 数据
 */
export function deleteCompanyApi(selectedId,id) {
  return request({
    url: `/api/Companies/${selectedId}?companyIds=${id}`,
    method: 'DELETE',
  });
  
};

/**
 * 手机号部分更新
 * @param id
 */
export function patchCompanyMobileApi(selectedId,data,ids ) {
  return request({
    url: `/api/Companies/${selectedId}/${ids}`,
    method: 'PATCH',
    data
  });
};
/**
 * 公司显示
 * @param id
 */
export function patchCompanyStateApi(data) {
  const { id, op, path, value } = data
  return request({
    url: `/api/Companies/${id}`,
    method: 'PATCH',
    headers: {
      isToken: true
    },
    data: [
      { op, path, value }
    ]
  })
}